﻿@model DishOrderItem
@{
    Layout = "~/Views/Shared/_LayoutForm.cshtml"; 
}
@Html.HiddenFor(m => m.Id)
@Html.HiddenFor(m => m.OrderId)
@Html.HiddenFor(m => m.DishId)
@Html.HiddenFor(m => m.SiteId)
@Html.HiddenFor(m => m.Code)
@Html.nbTextBoxFor(m => m.Name).ReadOnly(true).Required()
@Html.nbDropDownListFor(m => m.MealType, "MealType").Required()
@Html.nbTextBoxFor(m => m.Count, new { onchange = "Javascript:CalaTotal()" }).Number()
@Html.nbDropDownListFor(m => m.Category, "DishType")
@Html.nbTextBoxFor(m => m.DishCost, new { onchange = "Javascript:CalaTotalCost()" }).Number()
@Html.nbTextBoxFor(m => m.TotalCost).Number().ReadOnly(true)
@Html.nbDateFor(m => m.Date).ReadOnly().Required()
@*@Html.nbTextBoxFor(m => m.DishPrice, new { onchange = "Javascript:CalaTotalPrice()" }).Number()
@Html.nbTextBoxFor(m => m.TotalPrice).Number().ReadOnly(true)*@
@Html.nbTextAreaFor(m => m.Remark)
<script type="text/javascript">
    function SelectDish(e) {
        OpenModalDialog('@Url.Action("Lookup", "DishRange")?Date=' + $('#Date').val(),
        {
            width: 620,
            height: 500,
            caption: "从大菜单中选择菜肴",
            onclose: function (data) {
                if (data) {
                    $("#DishId").val(data.DishId);
                    $("#Code").val(data.Code);
                    $("#Name").val(data.Name);
                    $("#Category").val(data.Category);
                    $("#DishCost").val(data.DishCost);
                    $("#DishPrice").val(data.DishPrice);
                }
            }
        });
    }
    function CalaTotal() {
        CalaTotalCost();
        CalaTotalPrice();
    }

    function CalaTotalCost() {
        var count = $("#Count").val();
        var dishcose = $("#DishCost").val();
        $("#TotalCost").val(parseFloat(count) * parseFloat(dishcose));
    }

    function CalaTotalPrice() {
        var count = $("#Count").val();
        var dishprice = $("#DishPrice").val();
        $("#TotalPrice").val(parseFloat(count) * parseFloat(dishprice));
    }
</script>
